{extend name="public/base" /}
{block name="head"}
    <title>爱代练</title>
    <meta charset="UTF-8">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <link href="__resource_path__/ui-framework/easyui-1.5.2/themes/metro/easyui-c5a176a3d4.css" rel="stylesheet" />
    <link href="__resource_path__/ui-framework/easyui-1.5.2/themes/icon-77a4ded0c8.css" rel="stylesheet" />

    <link href="__resource_path__/ui-framework/bootstrap/3.0.3/css/bootstrap-a067b6d831.min.css" rel="stylesheet" />
    <link href="__resource_path__/ui-framework/bootstrap-daterangepicker/css/daterangepicker-886dba62c4.css" rel="stylesheet" />
    <link href="__resource_path__/ui-framework/font-awesome/css/font-awesome-a81d284b37.css" rel="stylesheet" />

    <link href="__resource_path__/ui-framework/admin-lte/css/AdminLET-7d58b99a7e.css" rel="stylesheet" />
    <link href="__static_path__/css/base-dc47892812.css" rel="stylesheet" />

    <link href="__resource_path__/ui-framework/jason/searchbox/css/searchbox-398327fb84.css" rel="stylesheet" />
    <link href="__resource_path__/ui-framework/jason/pager/css/pager-f077f5e880.css" rel="stylesheet" />
    <link href="__resource_path__/ui-framework/jason/status/css/status-5f59ab3856.css" rel="stylesheet" />
    <link href="__resource_path__/ui-framework/jason/selector/css/selector-23060c280e.css" rel="stylesheet" />
    <link href="__resource_path__/ui-framework/jason/button/css/button-5ef10c798a.css" rel="stylesheet" />
    <link href="__resource_path__/ui-framework/jason/orderarrow/css/orderarrow-dcf8eba7d1.css" rel="stylesheet" />

    <link href="__static_path__/css/table-0e491bc98f.css" rel="stylesheet" />
    <link href="__static_path__/css/easyui-ext-372f902530.css" rel="stylesheet" />

{/block}
{block name="content"}
<section class="content">
        <div class="container" style="float:left;padding:10px;">
            <div class="row">
                <div class="col-md-7">
                    <div style="min-width:650px;">
                    <form action="" method="post" class="ajaxform">
                        <ul class="add-list filter-box">
                            {foreach $imports as $vo}
                            <li class="clearfix" style="float: left;">
                               
                                <div class="items fl">
                                    <div id="lblOrderSource" style="display:inline;">{$vo.name}</div>：
                                </div>
                                {if($vo['value']=='number')}
                                    <div class="fill-items fl">
                                        <input placeholder="{$vo.unit}" style="margin: 0px; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 148px;border:1px solid #b0b0b0" type="text" name="{$vo.value}" data="{$vo.name}">
                                        <a href="javascript:void(0)" onclick="checkNumber()" style="color:blue">重单验证</a>
                                    </div>
                                {else /}
                                    {if($vo['is_text']==1)}
                                         <div class="fill-items fl" style="height:auto;">
                                            <div>
                                                <textarea  style="width:394px;height:50px;line-height:20px;padding:5px;" data="{$vo.name}" name="{$vo.value}"></textarea>
                                            </div>
                                        </div>
                                    {else /}
                                        <div class="fill-items fl" id="source">
                                            <input  placeholder="{$vo.unit}" style="margin: 0px; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 148px;border:1px solid #b0b0b0" type="text" name="{$vo.value}" data="{$vo.name}">
                                        </div>
                                    {/if}
                                {/if}
                               
                                
                          

                            </li>
                           {/foreach}
                            <li class="clearfix">
                                <div class="items fl">接单客服：</div>
                                <div class="fill-items fl">
                                    <select style="margin: 0px; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 148px; ime-mode: disabled;border:1px solid #b0b0b0" name="customer_id">
                                    {foreach $customer as $vo}
                                    <option value="{$vo.id}">{$vo.mobile}</option>
                                    {/foreach}
                                    </select>
                                </div>
                                <div class="items fl">订单标签：</div>
                                <div class="fill-items fl">
                                   <select style="margin: 0px; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 100px; ime-mode: disabled;border:1px solid #b0b0b0" name="tags_id">
                                   {foreach $tags as $vo}
                                     <option value="{$vo.id}">{$vo.title}</option>
                                   {/foreach}
                                </select>
                                急：
                                <input style="height:30px;line-height:30px;" type="checkbox" name="is_urgent" value="1">
                                </div>
                            </li>
                        </ul>
                        <ul class="add-list filter-box" id="extendFields" style="margin-top:-19px;">
                        </ul>
                        <ul class="add-list filter-box" style="margin:5px auto;">
                            <li class="clearfix">
                                <div class="items fl"></div>
                                <div class="fill-items fl">
                                    <a id="btnSubmit" href="javascript:" class="btn-action fl">创建订单</a>
                                    <a id="btnSubmitSend" class="btn-action fl ml10" style="display:none">创建并发单</a>
                                </div>
                            </li>
                        </ul>
                        </form>
                        <div id="priceHelper" style="display:none;">
                            <table class="order mt10">
                                <tbody><tr class="project header">
                                    <td>#</td>
                                    <td>代练项目</td>
                                    <td>发单价</td>
                                    <td>接单前等待（分钟）</td>
                                    <td>发布时间</td>
                                </tr>
                                </tbody><tbody id="priceData">

                            </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="col-md-5" style="border-left:1px dashed #c0c0c0;">
                    <div class="order-detail" style="width:320px;margin:0px auto;">
                        <div style="margin:5px auto;">
                            <input class="easyui-combobox combobox-f combo-f textbox-f" id="importGame" data-options="width:132,editable:false,valueField:'ID',textField:'Name',prompt:'请选择游戏',url:'/game/array',method:'get'" style="display: none;">
                            <a href="/index/system/import" class="ml10">设置默认导入游戏</a>
                            <a href="javascript:void(0)" class="easyui-linkbutton easyui-tooltip tooltip-f l-btn l-btn-small l-btn-plain" data-options="iconCls:'icon-help',plain:true" title="" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text l-btn-empty">&nbsp;</span><span class="l-btn-icon icon-help">&nbsp;</span></span></a>
                        </div>
                        <div>
                            <textarea id="content" rows="18" style="display:block;width:100%;text-indent:0px;font-size:12px;padding:5px;line-height:18px;" placeholder="导入文本粘贴在这里">
{foreach $imports as $vo}
{if($vo['status']==1)}
{$vo.name}:
{/if}
{/foreach}
                            </textarea>
                        </div>
                        <div class="container" style="width:100%;text-align:center;">
                            <div class="row" style="margin:2px 0px;font-size:12px;">
                                查看<input class="easyui-combobox combobox-f combo-f textbox-f" id="gameText" data-options="width:100,editable:false,valueField:'ID',textField:'Name',prompt:'请选择游戏'" style="display: none;">导入文本
                                <a href="/index/system/import" style="font-size:15px;" target="_blank">设置导入模板</a>
                            </div>
                            <div class="row">
                                <div style="width:320px;margin:2px auto;">
                                    <a href="javascript:" class="btn-action fl" id="btnImport">导入</a>
                                    <a href="javascript:" class="btn-action fl ml10" id="btnClear">清空</a>
                                </div>
                            </div>
                            <div class="row mt10">
                                <span style="font-size:12px; line-height:18px;text-align:left;">
                                    <p style="font-weight:bold;">操作步骤</p>
                                    <p class="mt10">* 将导入文本发给玩家填写；</p>
                                    <p>* 复制玩家填写好的导入文本，粘贴至导入框内；</p>
                                    <p>* 点击导入按钮将资料导入至左侧表格内，点击提交按钮，此时订单已创建完毕。</p>
                                </span>
                            </div>
                            <div class="row mt10">
                                <span style="font-size:12px; line-height:18px;text-align:left;">
                                    <p style="font-weight:bold;">注意事项</p>
                                    <p class="mt10">* 不能<span style="color:red;">删减</span>或<span style="color:red;">修改</span>导入文本，但可改变各导入项的顺序；</p>
                                    <p>* 选择对应的游戏才能导入成功（可以在导入文本设置里编辑自己需要的导入文本）。</p>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</section>
{/block}
{block name="script"}
<script src="__resource_path__/libs/jquery/jquery-1-4ed679c998.11.3.min.js"></script>
<script src="__resource_path__/libs/ajaxfileupload-20caa375ef.js"></script>
<script src="__resource_path__/ui-framework/bootstrap/3.0.3/js/bootstrap-7b3098bda9.min.js"></script>
<script src="__resource_path__/ui-framework/bootstrap-daterangepicker/js/moment-zh_cn-3d8809ccd6.js"></script>
<script src="__resource_path__/ui-framework/bootstrap-daterangepicker/js/daterangepicker-bca1a72d19.js"></script>
<script src="__resource_path__/ui-framework/admin-lte/app-bf15eda982.js"></script>

<!-- <script src="__resource_path__/ui-framework/easyui-1.5.2/jquery-623c7c7acd.easyui.min.js"></script>
<script src="__resource_path__/ui-framework/easyui/plugins/jquery-1db0d9c758.checkbox.js"></script>
<script src="__resource_path__/ui-framework/jason/searchbox/searchbox-3fc48f72fe.js"></script>
<script src="__resource_path__/ui-framework/jason/pager/pager-0646a093e8.js"></script>
<script src="__resource_path__/ui-framework/jason/status/sky-2d329149af.tools.status.js"></script>
<script src="__resource_path__/ui-framework/jason/screenshot-paste-0b91b6bd4a.js"></script>
<script src="__resource_path__/ui-framework/jason/selector/selector-a0b18d2070.js"></script>
<script src="__resource_path__/ui-framework/jason/button/button-71f76513c7.js"></script>
<script src="__resource_path__/ui-framework/jason/orderarrow/orderarrow-1bbd8bcec2.js"></script>
<script src="__resource_path__/libs/clipboard-892cfb62e7.min.js"></script>
<script src="__resource_path__/libs/template-2d62718262.js"></script>
<script src="__resource_path__/libs/jquery-d833fe9e58.cookie.js"></script>
<script src="__resource_path__/libs/common-21f077db5b.js"></script>
<script src="__resource_path__/libs/tools-4754a28493.js"></script>
<script src="__resource_path__/libs/basePage-d30d50f2ce.js"></script>
<script src="__static_path__/js/order-627da7e816.js"></script> -->

<script src="__static_path__/js/layer/layer.js"></script>
<script type="text/javascript">
    $().ready(function () {
        var url = $('#hdnURL').val();

        $('.sidebar .treeview').each(function (index, item) {
            var btn = $(this).children("a").first();
            var menu = $(this).children(".treeview-menu").first();

            $(this).find('a').each(function (index, item) {
                if ($(item).attr('href') == url) {
                    menu.show();
                    btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
                }
            });
        });
    });

$('#btnImport').click(function(){
    var content = $('#content').val();
    content=content.split("\n");
    for(var i=0;i<content.length;i++){
        var data = content[i].split(':');
        $('input[data='+data[0]+']').val(data[1]);
        $('textarea[data='+data[0]+']').val(data[1]);
    }
})

function checkNumber(){
    var number = $('input[name=number]').val();
    if (!number) {
      layer.msg('编号不能为空');
      return;  
    }
    $.post('checkNumber',{number:number},function(res){
          if (res.code==1) {
              layer.msg(res.msg);
          }else{
             layer.msg(res.msg);
          }
    })
}


$('#btnSubmit').click(function(){
    $('.ajaxform').submit();
})
$('.ajaxform').submit(function(e){
     e.preventDefault();
     var form = $(this).serialize();
     $.post('{:url("add")}',form,function(res){
         if (res.code==1) {
            layer.msg(res.msg);
            //window.parent.location.reload();
          }else{
             layer.msg(res.msg);
          }
     })
})

var content = $('#content').val();
$('#btnClear').click(function(){
    $('#content').val(content);
})
</script>
{/block}